package com.aaa.service.impl;
import com.aaa.dao.UserMapper;
import com.aaa.entity.Fuser;
import com.aaa.entity.SecurityUser;
import com.aaa.entity.User;
import com.aaa.service.UserServiceDao;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.catalina.mapper.Mapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserServiceDao {
     @Resource
     UserMapper userMapper;
    @Override
    public SecurityUser loadUserByUsername(String username) {
        List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("username", username));
        if (userList.size()==1){
            User user = userList.get(0);
            return new SecurityUser(user.getUsername(),user.getPassword(),user.getState()==1,"aaa",user.getUid());
        }
        return null;
    }
}
